package com.yanqu.road.server.cmd.activity.cat;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CatProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.cat.CatActivity;
import com.yanqu.road.server.manager.activity.cat.CrossCatActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C_CAT_ACTIVITY_UPLOAD_NOTICE, desc = "公告上传")
public class CrossCatUploadNoticeCmd extends CrossCommand {

    int activityId;
    PlayerProto.PlayerBaseTempMsg player;
    int goodsId;
    long playerId;
    int type;
    String reward = "";

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        CatProto.CrossCatUploadNoticeReqMsg reqMsg = CatProto.CrossCatUploadNoticeReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        player = reqMsg.getPlayer();
        goodsId = reqMsg.getGoodsId();
        playerId = packet.getPlayerId();
        type = reqMsg.getType();
        reward = reqMsg.getReward();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CatActivity activity = CrossCatActivityMgr.getCatActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }

        activity.uploadNotice(playerId, goodsId, PlayerBasePb.parseToUserBaseInfo(player), type, reward);
    }

    @Override
    public void sendData() {

    }
}
